import { View, Text } from '@tarojs/components'
import { useLoad,useDidShow } from '@tarojs/taro'
import './index.scss'
import { AtAvatar } from 'taro-ui';
import { AtCountdown ,AtNoticebar } from 'taro-ui'
import Request from './../../utils/request'
import { useEffect,useState } from 'react';

import moment from 'moment'
import request  from '../../utils/request'
import Taro from '@tarojs/taro'
export default function Index () {
  const [list,setList] = useState([]);
  useLoad(() => {
    console.log('Page loaded.')
  })
   const getList = ()=>{
    //admin/login
    request.post('app/c/course/list',{"paging":{"pageNum":1,"pageSize":222222}}).then((res)=>{
      console.log(res);
      setList(res.data||[] );
    })
  }
  useEffect(()=>{
    getList();
  },[])
  return (
    <div className='index-page'>
      {
        list.map((item,index)=>{
          return <div key={index} onClick={()=>{
             Taro.navigateTo({url:'/pages/kcdetail/index?id='+item.id})
          }} className="course-item">
            <div className="course-title">{item.title}</div>
            <div className="course-sub-title">{item.subTitle}</div>
            <div className="course-brief">{item.brief}</div>
            <div className="course-time">{moment(item.startTime).format('YYYY-MM-DD HH:mm')} - {moment(item.endTime).format('HH:mm')}</div>
          </div>
        })
      }
    </div>
  )
}
